package 条件判断;

import java.util.Scanner;

public class D02 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个四位数：");
        int  a = sc.nextInt();
        int  z = a % 10 ;
        int  x = a / 10 % 10 ;
        int  c = a / 100 % 10 ;
        int  v = a / 1000;
        int b = z + x + c + v ;
        if ( a > 999  &&  a < 10000) {
            System.out.println("输入的四位数为：" + a);
            System.out.println("个位为：" + z);
            System.out.println("十位为：" + x);
            System.out.println("百位为：" + c);
            System.out.println("千位为：" + v);
            System.out.println("四数和为：" + b);
        }else {
            System.out.println("输入错误！！");
        }
    }
}
